package com.atguigu12.wapper.exer1;

import java.util.Scanner;
import java.util.Vector;

/**
 * ClassName: ScoreTest
 * Package: com.atguigu12.wapper.exer1
 * Description:
 *
 * @Author ZY
 * @Create 16:28
 * @Version 1.0
 */
public class ScoreTest {
    public static void main(String[] args) {

        //1.创建Vector对象:
        Vector v = new Vector();

        Scanner scanner = new Scanner(System.in);

        int maxScore = 0;//记录最高分

        //2.从键盘获取多个学生的成绩,存放到v中(以负数代表输入结束)
        while(true){

            System.out.println("请输入学生成绩(以负数代表输入结束):");
            int intScore = scanner.nextInt();

            if(intScore < 0){
                break;
            }

//            //装箱: int --> Integer对象
//            Integer score = Integer.valueOf(intScore);
//            //添加学生成绩到容器v中
//            v.addElement();

            //自动装箱
            v.addElement(intScore);

            //3. 获取学生成绩的最大值
            if(maxScore < intScore){
                maxScore = intScore;
            }


        }
        
        //4.依次获取v中的每个学生成绩，与最高分进行比较，最后评级输出
        for (int i = 0; i < v.size(); i++) {
            //方式1：
            Object objScore = v.elementAt(i);
//            Integer integerScore = (Integer) objScore;
//            //拆箱
//            int score = integerScore.intValue();

            //方式2：
            int score = (Integer) objScore;
            char grade = ' ';
            if(maxScore - score <= 10){
                grade = 'A';
            } else if (maxScore - score <= 20) {
                grade = 'B';
            } else if (maxScore - score <= 30) {
                grade = 'C';
            }else{
                grade = 'D';
            }
            System.out.println("student" + i + "score is " + score + ",grade is " + grade);
        }



    }
}
